# include <bits/stdc++.h>
using namespace std;

inline char getc() {
	static char buf[1 << 18], *fs, *ft;
	return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int gn() {
	int k = 0, f = 1;
	char c = getc();
	for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
	for(; isdigit(c); c = getc()) k = k * 10 + c - '0';
	return k * f;
}

int n, m, mp[22][502], mx = -0x7fffffff, ans, ck[502];

int dp(int z) { 
    int c0, c1;
    bool flag = 1;
    memset(ck, 0, sizeof(ck));
    for(int i = 0; i < n; i++) { 
        if(z & (1 << i)) { 
            for(int j = 0; j < m; j++) { 
                ck[j] += mp[i][j];
            }
        }
    }
    for(int j = 0; j < m; j++) { 
        if(ck[j] > 0) { 
            flag = 0;
            break;
        }
    }
    if(flag) return -0x7fffffff;
    c0 = c1 = 0;
    for(int i = 0; i < m; i++) { 
        if(i & 1) { 
            c1 = max(c1, ck[i] + c0);
        } else { 
            c0 = max(c0, ck[i] + c1);
        }
    }
    return max(c0, c1);
}

void dfs(int p, int l, int z) { 
    if(p == n) { 
        ans = max(dp(z), ans);
        return;
    }
    if(l == -1 || (p - l) & 1) // 选当前行
        dfs(p + 1, p, z | (1 << p));
    dfs(p + 1, l, z);
}

int main() { 
# ifndef LOCAL
	freopen("cfyw.in", "r", stdin);
	freopen("cfyw.out", "w", stdout);
# endif
	n = gn();
	m = gn();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			mx = max(mx, mp[i][j] = gn());
		}
	}
    if(mx <= 0) { 
        printf("%d\n", mx);
        return 0;
    }
    dfs(0, -1, 0);
	printf("%d\n", ans);
	return 0;
}
